<?php
use \think\facade\Request;
use think\helper\Str;
function createUrl(string $url = '', array $vars = [], $suffix = true, $domain = false){
    $arr = explode("/",$url);
    if(count($arr) == 1){
        $url = Request::controller(true) . '/' . $url;
    }else if(count($arr) == 2){
        // app('http')->getName()
    }

    return (string)url($url,$vars,$suffix, $domain);
}

//生成订单号
function generate_order_no(){
    return Str::random(40).date('YmdHis');
}
//格式化时间
function format_time(?int $time)
{
	if(!$time){
		$time=time();
	}
	return date('Y-m-d H:i:s',$time);
}

function get_exception_message($e,$msg="系统错误,稍后重试")
{
    return env('APP_DEBUG') ? (($e instanceof \Exception ) ? $e->getMessage() : $msg) : $msg;
}

function p($arr){
    if(isset($arr) && !empty($arr)) {
        echo '<pre>';
        print_r($arr);
        echo '</pre>';
    }
}
